﻿
using System;
using System.Collections.Generic;
using System.IO.IsolatedStorage;
namespace WCYCReader.Utility
{
    public class SettingHelper
    {
        public static IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

        public static void DeleteAllSettings()
        {
            foreach (string str in settings.Keys)
            {
                DeleteSettings(str);
            }
        }

        public static void DeleteSettings(string key)
        {
            settings.Remove(key);
        }

        public static List<T> GetAllValues<T>()
        {
            List<T> list = new List<T>();
            foreach (string str in settings.Keys)
            {
                T local;
                settings.TryGetValue<T>(str, out local);
                list.Add(local);
            }
            return list;
        }

        public static object GetValueFromSettings(string key)
        {
            object obj2;
            settings.TryGetValue<object>(key, out obj2);
            return obj2;
        }

        public static bool IsSettings(string key)
        {
            return settings.Contains(key);
        }

        public static void SaveInToSettings(string key, object value)
        {
            DeleteSettings(key);
            settings.Add(key, value);
            settings.Save();
        }
    }
}

